new Vue({
    el: "#content",
    data: {
        articleId: '',
        article: {},
        favorites: 0, //收藏次数
        isFollow: "", //是否收藏
        userList: [] //你关注的用户页关注了
    },
    methods: {
        detail: function () {
            axios({
                method: "get",
                url: `/article/detail/${this.articleId}`
            }).then(res => {
                if (res.data.flag) {
                    this.article = res.data.data.article;
                    this.favorites = res.data.data.favorites;
                    this.isFollow = res.data.data.isFollow;
                    this.userList = res.data.data.userList;
                }
            });
        },
        doFavorite: function (articleId) {
            axios({
                method: "get",
                url: `/article/favorite/${articleId}`
            }).then(res => {
                layer.msg(res.data.message);
                if (res.data.flag) {
                    this.favorites = res.data.data;
                    this.isFollow = 1;
                } else {
                    this.favorites = res.data.data;
                    this.isFollow = 0;
                }
            });
        },
        detailUser: function (user) {
            if (user.isSecret == 0) {
                layer.msg("对方设置了私秘！");
                return;
            }
            sessionStorage.setItem("userId", user.id);
            location.href = "/html/user_detail.html";
        }
    },
    created: function () {
        this.articleId = sessionStorage.getItem("articleId");
        this.detail();
    }
})